package com.threeti.mecool.core.infrastructure.persistence.plan;

import com.threeti.mecool.core.domain.model.plan.pojo.Job;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * <p/>
 * zhaoxu @ 2012-05-23 15:20
 * <p/>
 */
public interface JobRepository extends JpaRepository<Job, Long>, JpaSpecificationExecutor<Job> {
    Job findByName(String name);

    /**
     * use getByCode instead
     */
    @Deprecated
    Job findByCode(String code);

    @Query("from Job where (removed is null or removed = 0) and code=?")
    List<Job> getByCode(String code);

    @Query("from Job where removed is null or removed = 0 order by name")
    List<Job> findAllActive();
}
